#----------------------------
# Name: Cam Clark
# Project: Madlibs.py
# Period: 2
# Start Date: 9/17/2013
# Last Revision Date: 10/2/2013
# Version: 2.0.1
#----------------------------

swearFilter = ["dumb",
               "stupid",
               "retard",
               "fuck",
               "shit",
               "cunt",
               "nigga",
               "cracka",
               "nigger",
               "motherfucker",
               "fuckshit",
               "dipshit",
               "dumbshit"
               "dumbass",
               "ass",
               "pussy",
               "dick",
               "penis",
               "vagina",
               "tits",
               "tit",
               "boob",
               "tittie",
               "titties",
               "penguin",
               "chair",
               "lamp",
               "park",
               "faggot",
               "fag",
               "asshole",
               "urethra",
               "penisfartvaginaboob",
               "Logan",
               "Obama",
               "nickelback",
               "anal",
               "oral",
               "vaginal",
               "doggy style",
               "missionary",
               "call of duty",
               "Justin Beiber",
               "Justin Timberlake",
               "smartass",
               "wise alec",
               "old people",
               "piss",
               "damn",
               "damnit",
               "dammit",
               "goddamnit",
               "goddammit",
               "KKK",
               "Ku Klux Klan",
               "666",
               "satan",
               "1337",
               "sim city",
               "gucci",
               "Lil Wayne",
               "hoes",
               "ho",
               "bitch",
               "asses",
               "dryfuck",
               "whore",
               "whores",
               "sluts",
               "slut",
               "sluts",
               "pussyhole",
               "Nicki Minaj",
               "gucci",
               "everything",
               "swears",
               "screw",
               "nail",
               "hammer",
               "lake",
               "dickhead",
               "farthead",
               "pooface",
               "fuzz",
               "po-po",
               "hell",
               "mega satan",
               "golf",
               "Syria",
               "Voldemort",
               "bastard",
               "biotch",
               "bastards",
               "biotches",
               "bitches",
               "shitface",
               "shitfuck",
               "fuckshit",
               "69",
               "-10",
               "porn",
               "porno",
               "pornography",
               "sex",
               "sexes",
               "sexism",
               "racism",
               "sexist",
               "racist",
               "cha-cha",
               "loaf",
               "fucknigga"
               "lucifer",
               "devil",
               "fuckniggashitcuntbitchassmotherfucker",
               "MILF",
               "mothafucka",
               "cum",
               "semen",
               "orgasm",
               "ejaculation",
               "cumshot",
               "moneyshot",
               "blowjob",
               "footjob",
               "handjob",
               "titjob",
               "titfuck",
               "17",
               ",",
               "over nine thousand",
               "over 9000",
               "9001",
               "pottymouth",
               "trucker mouth",
               "sailor mouth",
               "sailor's tongue",
               "retarded",
               "cookie",
               "cook",
               "chef",
               "sneaker",
               "Hubert's",
               "douche",
               "douchebag",
               "douchewaffle",
               "dickwad",
               "dickbiscuit",
               "monkeysinabarrel",
               "tata",
               "tatas",
               "dicks",
               "cunts",
               "fucking",
               "fucked",
               "will fuck",
               "has been fucked",
               "had been fucked",
               "going to be fucked",
               "about to be fucked",
               "will be fucked",
               "will be fucking",
               "about to be fucking",
               "shits",
               "shitstain",
               "shitstains",
               "cunts",
               "megacunts",
               "megadicks",
               "megadick",
               "assholes",
               "douches",]

stateList = ["Alabama", 
            "Alaska", 
            "Arizona", 
            "Arkansas", 
            "California", 
            "Colorado", 
            "Connecticut", 
            "Delaware",
            "Florida",
            "Georgia",
            "Indiana",
            "Iowa",
            "Kansas",
            "Kentucky",
            "Louisiana",
            "Maine",
            "Maryland",
            "Massachusetts",
            "Michigan",
            "Minnesota",
            "Nebraska",
            "Nevada",
            "New Hampshire",
            "New Jersey",
            "New Mexico",
            "New York",
            "North Carolina",
            "North Dakota",
            "Ohio",
            "Oklahoma",
            "South Carolina",
            "South Dakota",
            "Tennessee",
            "Texas",
            "Utah",
            "Vermont",
            "Virginia",
            "Washington",
            "West Virginia",
            "Wisconsin",
            "Hawaii",
            "Idaho",
            "Illinois",
            "Mississippi",
            "Missouri",
            "Montana",
            "Oregon",
            "Pennsylvania",
            "Rhode Island",
            "Wyoming",
            "Washington D.C."]

langList = ["English",
            "Spanish"]
            
if len(stateList) != 51:
    print"????"
    
def displayStartScreen():
    print "Madlibs"
    raw_input("Press Enter to Continue")

def displayEndScreen():
    print "Goodbye"
    raw_input("Press Enter to Exit")

def langMenuOption(options):
    option = ""
    goodOption = False
    while not goodOption:
        option = raw_input("Enter Number or Q> ")
        option = option.upper()
        if option.isdigit():
            if option == "1":
                goodOption = True
                print "You are now playing MadLibs in English."
            elif option == "2":
                goodOption = True
                print "I don't know Spanish."
                displayEndScreen()
                exit()
        if option == "Q":
            goodOption = True
            displayEndScreen()
            exit()
        if not goodOption:
            print "Please pick a valid option!"
    return option    

def langMenu(options):
    print "Choose a Language"
    print "[1] English"
    print "[2] Spanish"
    option = langMenuOption(options)    
    return option    

def getLang():
    lang = ""
    goodLang = False
    while not goodLang:
        lang = raw_input("Enter a language: ") 
        if lang in langList:
            goodLang = True
        else:
            print "Enter a valid language, English or Spanish please."
        if not goodLang:
            print "Try again"
    return lang

def getMenuOption(maxOption):
    option = ""
    goodOption = False
    while not goodOption:
        option = raw_input("Enter Number or Q> ")
        option = option.upper()
        for num in range(1, maxOption+1):
            if option == str(num):
                goodOption = True
        if option == 'Q':
            goodOption = True
        if option == '4':
            print "You suck"
            goodOption = False
        if not goodOption:
            print "Please pick a valid option!"
    return option

def menu(options):
    print "------Please Select a Story------"
    print " [1] The End of the Day"
    print " [2] My New Pet"
    print " [3] Over the Rainbow"
    print " [Q] Quit"
    print "----------------------------------"
    option = getMenuOption(options)
    return option

def getWord(prompt):
    word = ""
    goodWord = False
    while not goodWord:
        word = raw_input(prompt)
        if word.lower() not in swearFilter:
            goodWord = True
        else:
            print "Naughty player...please be polite."
        if not goodWord:
            print "Try again"
    return word

def getNumber(prompt, max = "", min = ""):
    num = ""
    goodNum = False
    while not goodNum:
        isNum = True
        num = raw_input(prompt)
        for character in num:
            if character not in "0123456789":
                isNum = False
        if min != "":
            if isNum:
                if float(num) < min:
                    isNum = False
        if max != "":
            if isNum:
                if float(num) > max:
                    isNum = False
        if isNum:
            goodNum = True
        else:
            print "Not a valid number, try again."
    return num

def getState(prompt):
    state = ""
    goodState = False
    while not goodState:
        state = raw_input(prompt)
        if state.capitalize() in stateList:
            goodState = True
        else:
            print "Not a valid U.S. state."
        if not goodState:
            print "Try again please."
    return state

def story1():
    place1 = getWord("Enter a place: ")
    noun1 = getWord("Enter a plural noun: ")
    propernoun1 = getWord("Enter a male person's name: ")
    noun2 = getWord("Enter another plural noun: ")
    verb1 = getWord("Enter a verb: ")
    verb2 = getWord("Enter another verb: ")
    animal1 = getWord("Enter a type of animal: ")
    noun3 = getWord("Enter a noun: ")
    story = "It was near the end of the day at"
    story += " " + place1 + ", "
    story += " " + place1 + " was filled with loads of"
    story += " " + noun1 + "."
    story += " " + "Now, there were usually a lot of " + noun1 + " at " + place1 + ", but today had been a(n) " + verb1 + " day."
    story += " At one point in the day, someone very " + verb2 + " came in,"
    story += " " + propernoun1 + " came in."
    story += " " + "When " + propernoun1 + " came in, he brought all his " + noun1 + " with him. " + noun2 +  " heard that " + propernoun1 + " had brought all of their " + noun1 + " to " + place1 + " and they soon brought all of their " + noun1 + " to " + place1 + " as well."
    story += " " + "And that's the tale of the day " + place1 + " got filled with loads of " + noun1 + "."
    story += " Oh, also " + propernoun1 + " brought his pet " + animal1 + " with him and his " + animal1 + " destroyed all of the " + noun3 + " at " + place1 + "."
    print story

def story2():
    name1 = getWord("Enter a name: ")
    age = getNumber("Enter a number: ")
    verb1 = getWord("Enter a verb: ")
    name2 = getWord("Enter another name: ")
    noun1 = getWord("Enter a noun: ")
    name3 = getWord("Enter a female name: ")
    adjective1 = getWord("Enter an adjective: ")
    adjective2 = getWord("Enter another adjective: ")
    story = "I got a new pet and I named it"
    story += " " + name1 + ". "
    story += "I think " + name1 + " is"
    story += " " + age + " years old, because he likes to"
    story += " " + verb1 + " a lot."
    story += " " + name1 + " reminds me of my old pet,"
    story += " " + name2 + ". He liked to do all the same stuff that " + name1 + " likes to do."
    story += " I kinda wish " + name2 + " was still alive, though. Unfortunately he died last year of a terrible"
    story += " " + noun1 + "."
    story += " My mother though, " + name3 + ", doesn't really like " + name1 + ", she thinks he's too " + adjective1 + "."
    story += " Personally, I think that " + name1 + " may be just a little bit too " + adjective1 + ", but I can live with it, it isn't that " + adjective2 + "."
    print story

def story3():
    state1 = getState("Enter a U.S. state: ")
    name1 = getWord("Enter a name: ")
    adjective1 = getWord("Enter an adjective: ")
    noun1 = getWord("Enter a plural noun: ")
    noun2 = getWord("Enter a singular noun: ")
    noun3 = getWord("Enter another plural noun: ")
    name2 = getWord("Enter the a type of person: ")
    story = "I don't think we're in"
    story += " " + state1 + " anymore,"
    story += " " + name1 + "."
    story += " It's awfully"
    story += " " + adjective1 + " here, I hope we can find some"
    story += " " + noun1 + " to save us from the"
    story += " " + noun2 + "."
    story += " If we can't find any " + noun1 + ", then we're in trouble. If we can't find " + noun1 + " then the only thing that can save us will be"
    story += " " + noun3 + "."
    story += " We should ask the locals if they know where any " + noun1 + " are. Oh, and I overheard some"
    story += " " + name2 + " talking about how they know where some " + noun3 + " might be. If we can't find " + noun1 + " then we'll track them down and ask where the " + noun3 + " are."
    story += "So the adventurers set out on their quest to find out where the " + noun1 + " is, and they found it after a few minutes of searching. The " + noun2 + " never even touched them and they lived happily ever after. The end."
    print story

def chooseStory():
    choice = ""
    while choice != 'Q':
        choice = menu(3)
        if choice == '1':
            story1()
        elif choice == '2':
            story2()
        elif choice == '3':
            story3()
        elif choice == 'Q':
            displayEndScreen()
            exit()
        else:
            print "Something Awful Occurred...yell at programmer!"
   
def run():
    choice = langMenu(2)
    if choice == '1':
        displayStartScreen()
        chooseStory()
    elif choice == '2':
        displayEndScreen()
        exit()
    elif choice == 'Q':
        displayEndScreen()
        exit()
    exit()
run()